require "Common/define"
require "Logic/Config"
require "Common/functions"

RedDotsWorldMapReceiveRobRewardHandler = {};
local this = RedDotsWorldMapReceiveRobRewardHandler;
function RedDotsWorldMapReceiveRobRewardHandler.init()
    CloseEvent(Config.EventType.Fresh_WorldMapReceiveRobReward, this.update)
    ListenEvent(Config.EventType.Fresh_WorldMapReceiveRobReward, this.update) 
    return this
end

--参数1： id，nil检查所有
function RedDotsWorldMapReceiveRobRewardHandler.getFlag(...)
    local msgId = ...
    local flag = Config.RedDotsFlagState.None
    local open_chapter = dataTable.getDataTableByStringId("t_global", 330 ,"f_int_value")
    local cur_chapter = logicMgr.MapManager.GetMapcfgByID(MapManager.getMapId()).f_ChapterId or 1
    if cur_chapter >= open_chapter  and Config.OpenPlunder == true then  
        local red1 = plunderHandler.GetRobReceiveRewardRedDotData()
        if red1 then
            flag = Config.RedDotsFlagState.Needful
        end
    end
    return flag
end

function RedDotsWorldMapReceiveRobRewardHandler.update()
    RedDotsManager.addBroadcast(Config.RedDotsType.WorldMapReceiveRobReward)
end
